<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 454px;
            height: auto;
            margin: 0 auto;
            /* background-color: blueviolet; */
        }

        .cook {
            width: 454px;
            background-color: aqua;
            height: 300px;
            margin: 0 auto;
        }

        .cook div {
            display: flex;
            justify-content: space-between;

        }

        span {
            /* width: ; */
            flex: 1;
            background-color: rgb(156, 149, 149);
            height: 50px;
            text-align: center;
            line-height: 50px;

        }

        span:nth-of-type(3) {
            background-color: orange;
        }
    </style>
</head>

<body>
    <div class="box">
        歌手: <input type="text">
        歌曲: <input type="text">
        <button>添加</button>
    </div>
    <div class="cook">
        <div>
            <span>歌手</span>
            <span>歌曲</span>
            <span>操作</span>
        </div>

    </div>
    <script>
        let ipt = document.querySelectorAll("input")
        let btn = document.querySelector("button")
        let cook = document.querySelector(".cook")

        function setItem() {
            let div = document.createElement("div")
            let span = document.createElement("span")
            let span1 = document.createElement("span")
            let span2 = document.createElement("span")
            span.innerHTML = ipt[0].value
            ipt[0].value = ""
            span1.innerHTML = ipt[1].value
            ipt[1].value = ""
            span2.innerHTML = "删除"
            cook.appendChild(div)
            div.appendChild(span)
            div.appendChild(span1)
            div.appendChild(span2)
            console.log(span2);
            span2.onclick = function () {
                this.parentNode.remove()
            }
        }
        btn.addEventListener('click', setItem)


    </script>
</body>

</html>